﻿
Imports System.IO
Imports osi.root.connector
Imports sf = osi.service.configuration.constants.static_filter
Imports fis = osi.service.configuration.constants.filter_selector

Public Module config_writer
    Private write_times As Int32 = 0

    Public Sub write()
        Using o As TextWriter = New StreamWriter(constants.file)
            o.WriteLine("spf=str-pat")
            o.WriteLine("spcf=str-pat-cache")
            o.WriteLine("sf=string")
            o.WriteLine("iif=int-int")
            o.WriteLine("ssf=str-ser")
            o.WriteLine("dcf=dbl-com")

            o.WriteLine("[section]")
            o.WriteLine("; try static filters first")
            o.WriteLine("b:unknownbuild$buildmode=unknownbuild")
            o.WriteLine("b:debugbuild$buildmode=debugbuild")
            o.WriteLine("b:releasebuild$buildmode=releasebuild")

            'it's a design issue, the >= and <= cannot work in default characters setting
            o.WriteLine("; try static filters and int_compare_selector")
            o.WriteLine("pc:>1$machine_type=normal")
            o.WriteLine("pc:>2$machine_type=strange")
            o.WriteLine("pc:>3$machine_type=powerful")
            o.WriteLine("pc:>7$machine_type=great")
            o.WriteLine("pc:<2$machine_type=lowend")

            'the string pattern match should be covered by match_pattern_test
            o.WriteLine("key1@spf:*p*a*t*t*e*r*n*1*=pattern1")
            o.WriteLine("key1@spf:*p*a*t*t*e*r*n*2*=pattern2")
            o.WriteLine("key1@spf:*p*a*t*t*e*r*n*3*=pattern3")
            o.WriteLine("key1=key1 no match")

            o.WriteLine("key2@spcf:*p*a*t*t*e*r*n*1*=pattern1")
            o.WriteLine("key2@spcf:*p*a*t*t*e*r*n*2*=pattern2")
            o.WriteLine("key2@spcf:*p*a*t*t*e*r*n*3*=pattern3")
            o.WriteLine("key2=key2 no match")

            o.WriteLine("key3@sf:string1=string1")
            o.WriteLine("key3@sf:string2=string2")
            o.WriteLine("key3@sf:string3=string3")
            o.WriteLine("key3=key3 no match")

            o.WriteLine("key4@iif:[0,100)=100")
            o.WriteLine("key4@iif:[100,200)=200")
            o.WriteLine("key4@iif:[200,300)=300")
            o.WriteLine("key4=400")

            o.WriteLine("key5@ssf:string1,string2,string3=string1,string2,string3")
            o.WriteLine("key5@ssf:string4,string5,string6=string4,string5,string6")
            o.WriteLine("key5@ssf:string7,string8,string9=string7,string8,string9")
            o.WriteLine("key5=string10")

            o.WriteLine("key6@dcf:>0&dcf:<100.1=100.1")
            o.WriteLine("key6@dcf:>100.1&dcf:<200.2=200.2")
            o.WriteLine("key6@dcf:>200.2&dcf:<300.3=300.3")
            o.WriteLine("key6@dcf:>300.3&dcf:<400.4=400.4")
            o.WriteLine("key6=500.5")

            o.WriteLine("write_times=" + Convert.ToString(_inc(write_times)))
        End Using
    End Sub
End Module
